import 'package:flutter/material.dart';
import 'package:xinxuan/utils/color_util.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class AddressBar extends StatelessWidget {

  final String consignee;
  final String mobile;
  final String provinceStr;
  final String cityStr;
  final String districtStr;
  final String address;
  final int id;
  final bool showRight;

  AddressBar({
    required this.consignee,
    required this.mobile,
    required this.provinceStr,
    required this.cityStr,
    required this.districtStr,
    required this.address,
    required this.id,
    this.showRight = true
  });

  @override
  Widget build(BuildContext context) {
    Widget _child = Text(
      '您暂没填写快递地址，请选填写快递地址'
    );
    if (id > 0) {
      _child = Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Text.rich(
            TextSpan(
              text: '$consignee ',
              style: TextStyle(
                color: textBlackColor,
                fontSize: 14.sp
              ),
              children: [
                TextSpan(
                  text: '$mobile',
                  style: TextStyle(
                    color: textSubtitleColor,
                    fontSize: 12.sp
                  )
                )
              ]
            )
          ),
          SizedBox(height: 2.h),
          Text(
            '$provinceStr$cityStr$districtStr$address',
            overflow: TextOverflow.ellipsis,
            maxLines: 2,
            style: TextStyle(
              color: textBlackColor,
              fontSize: 14.sp
            ),
          )
        ],
      );
    }
    return Container(
      height: 80.h,
      color: bgWhiteColor,
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      child: Row(
        children: [
          Image.asset(
            'assets/icons/icon_address_w.png',
            width: 30.w,
            height: 30.w,
            fit: BoxFit.cover,
          ),
          Expanded(child: Container(
            padding: EdgeInsets.symmetric(horizontal: 12.w),
            child: _child,
          )),
          showRight ? Image.asset(
            'assets/icons/icon_arrow_right.png',
            width: 15.w,
            height: 15.w,
            fit: BoxFit.cover,
          ) : Container(),
        ],
      ),
    );
  }
}